<?php

namespace App\Console\Commands\Mybank\Tools;

use App\Kuafu\Mybank\Model\MybankBatchNoRecordModel;
use App\Kuafu\Mybank\Model\MybankBillRecordModel;
use App\Kuafu\Mybank\Model\MybankVostroBillModel;
use App\Kuafu\Mybank\Service\MybankService;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Log;

class CreateBillRecordDistribute extends Command
{

    protected $signature = 'mybank:tools:create-bill-record-distribute';


    protected $description = '账户对账+批次创建_手动';


    public function handle()
    {
        Artisan::call('mybank:query-account-balance');

        $time = time();

        $date      = '20230908';
        $startTime = '1694124851';
        $dateTime  = date('Y-m-d H:i:s');

        $batchNoCount = MybankBatchNoRecordModel::getCount(MybankBatchNoRecordModel::DEFAULT_FLAG_MARK);

//        if ($batchNoCount > 0) {
//            Log::channel('mybank')->notice('网商银行账户对账-有未处理完成的批次：', [
//                'batchNoCount' => $batchNoCount,
//                'msg'          => '上一个批次完成后再创建新的批次',
//            ]);
//            return;
//        }

//        dd(1);
//
//        //饿了么外卖账单数据
//        $res = MybankService::matchBillRecordByDate($date, $time, MybankBillRecordModel::SOURCE_ELE);
//        if ($res['code'] == 200) {//批次创建完成 等待回调
//            return;
//        }

//
//        //美团外卖账单数据
//
//        $res = MybankService::checkBillRecord($startTime, $date, $time, MybankBillRecordModel::SOURCE_MEITUAN);
//        if ($res['code'] == 200) {//批次创建完成 等待回调
//            return;
//        }
//
//
//        //堂食账单数据
//        //查询堂食提现订单时间为1天前
//        $startTime = strtotime(date('Y-m-d', strtotime('-1 day')));//每天早上处理查询1天前的账单
//        if (config('app.env') == 'dev' || config('app.env') == 'test' || config('app.env') == 'qa') {
//            $startTime = $time;
//        }
//        $res = MybankService::matchBillRecordByDate($date, $time, MybankBillRecordModel::SOURCE_CANTEEN);
//        if ($res['code'] == 200) {//批次创建完成 等待回调
//            return;
//        }
//

    }

}
